/**
 * 
 */
package br.com.devschool.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import br.com.devschool.util.BaseEntity;

/**
 * @author ATILLA
 *
 */

@Entity
@Table
public class Grade extends BaseEntity implements Serializable{

	private static final long serialVersionUID = 4285220907662210079L;

	private String 				codigo;
	private Date 				dataCadastro;
	private Integer 			totalCargaHoraria;
	private Curso 				curso;
	private Set<Disciplina>	disciplinas;
	
	public Grade(Integer id, String codigo, Date dataCadastro,
			Integer totalCargaHoraria, Curso curso, Set<Disciplina> disciplinas) {
		super(id);
		this.codigo 			= codigo;
		this.dataCadastro 		= dataCadastro;
		this.totalCargaHoraria 	= totalCargaHoraria;
		this.curso 				= curso;
		this.disciplinas 		= disciplinas;
	}
	
	public Grade() { }

	public String getCodigo() {
		return codigo;
	}

	public void setCodigo(String codigo) {
		this.codigo = codigo;
	}

	@Column(name="data_cadastro")
	@Temporal(TemporalType.DATE)
	public Date getDataCadastro() {
		return dataCadastro;
	}

	public void setDataCadastro(Date dataCadastro) {
		this.dataCadastro = dataCadastro;
	}

	@Column(name="total_carga_horaria")
	public Integer getTotalCargaHoraria() {
		return totalCargaHoraria;
	}

	public void setTotalCargaHoraria(Integer totalCargaHoraria) {
		this.totalCargaHoraria = totalCargaHoraria;
	}

	@OneToOne
	@JoinColumn(name="id_curso")
	public Curso getCurso() {
		return curso;
	}

	public void setCurso(Curso curso) {
		this.curso = curso;
	}

	@ManyToMany
	@JoinTable(name="grade_has_disciplina", 
		joinColumns={
			@JoinColumn(name="id_grade")
		},
		inverseJoinColumns={
			@JoinColumn(name="id_disciplina")
		}
	)
	public Set<Disciplina> getDisciplinas() {
		return disciplinas;
	}

	public void setDisciplinas(Set<Disciplina> disciplinas) {
		this.disciplinas = disciplinas;
	}
	
}
